package com.medata.service.impl;

import com.medata.dataObject.DefaultValueTable;
import com.medata.repository.DefaultValueTableRepository;
import com.medata.service.DefaultValueTableService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.util.List;

/**
 * @author ：zb
 * @date ：Created in 2019/5/10 0010 11:06
 * @description：
 */
@Service
public class DefaultValueTableServiceImpl implements DefaultValueTableService {
    @Autowired
    private DefaultValueTableRepository tableRepository;

    @Override
    public List<DefaultValueTable> findByRefId(Integer RefID) {
        List<DefaultValueTable> tables = tableRepository.findByRefId(RefID);
        return tables;
    }

    @Override
    public String saveOrUpdate(DefaultValueTable defaultValueTable) {
        tableRepository.save(defaultValueTable);
        return "1";
    }

    @Override
    public DefaultValueTable findByDefValues(String value) {
        DefaultValueTable valueTable = tableRepository.findByDefValues(value);
        return valueTable;
    }

    @Override
    public DefaultValueTable findByDefValuesAndRefId(String value, Integer refID) {
        DefaultValueTable table = tableRepository.findByDefValuesAndRefId(value, refID);
        return table;
    }

    @Override
    @Transactional
    public void delete(DefaultValueTable table) {
        tableRepository.delete(table);
    }
}
